package com.yztc.orangeentertainment.ui.main.articlecommentall;

import android.content.Context;

import com.yztc.orangeentertainment.bean.articlecommentall.ArticleCommentAllListBean;
import com.yztc.orangeentertainment.config.ChannalUrlConfig;
import com.yztc.orangeentertainment.config.SubscribeUrlConfig;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by My on 2016/10/14.
 */
public class ArticleCommentAllPresenter implements ArticleCommentAllContract.Presenter {
    private ArticleCommentAllContract.Modle modle;
    private ArticleCommentAllContract.View view;

    public ArticleCommentAllPresenter(ArticleCommentAllContract.View view) {
        this.view = view;
        this.modle=new ArticleCommentAllModle();
    }

    @Override
    public void getArticleCommentAllFromNet(Context context, int id, int page) {
        Map<String,String> map=new HashMap<>();
        map.put(ChannalUrlConfig.Params.ID, id+"");
        map.put(ChannalUrlConfig.Params.PAGE,page+"");
        map.put(SubscribeUrlConfig.Params.TS,SubscribeUrlConfig.All_DefaultVaule.TS_VALUE);
        String type=ChannalUrlConfig.PATH.URL_CHANNALCOMMENT_TYPE;
        map.put(SubscribeUrlConfig.Params.MAC, SubscribeUrlConfig.All_DefaultVaule.MAC_VALUE);
        map.put(SubscribeUrlConfig.Params.UID, SubscribeUrlConfig.All_DefaultVaule.UID_VALUE);
        map.put(SubscribeUrlConfig.Params.PF, SubscribeUrlConfig.All_DefaultVaule.PF_VALUE);
        map.put(SubscribeUrlConfig.Params.NET, SubscribeUrlConfig.All_DefaultVaule.NET_VALUE);
        map.put(SubscribeUrlConfig.Params.ACCESSTOKEN, SubscribeUrlConfig.All_DefaultVaule.ACCESSTOKEN_VALUE);
        map.put(SubscribeUrlConfig.Params.CHANNEL, SubscribeUrlConfig.All_DefaultVaule.CHANNEL_VALUE);
        map.put(SubscribeUrlConfig.Params.VER, SubscribeUrlConfig.All_DefaultVaule.VER_VALUE);
        map.put(SubscribeUrlConfig.Params.RES, SubscribeUrlConfig.All_DefaultVaule.RES_VALUE);
        modle.getArticleCommentAll(type, map, new OnLoadArticleCommentAllListener() {
            @Override
            public void onSuccess(List<ArticleCommentAllListBean> list) {
                view.onArticleCommentAllSucess(list);
            }

            @Override
            public void onFailure(String e) {
                view.onArticleCommentAllFaild(e);
            }
        },context);
    }

    @Override
    public void getArticleCommentAllFromDb() {
        modle.getArticleCommentAllFromDb(new OnLoadArticleCommentAllListener() {
            @Override
            public void onSuccess(List<ArticleCommentAllListBean> list) {
                view.onArticleCommentAllSucess(list);
            }

            @Override
            public void onFailure(String e) {
                view.onArticleCommentAllFaild(e);
            }
        });
    }
}